/**
 * CharacterPane.java
 * 
 * @author	Joe Scharnitzke
 * Date: 	May 31, 2011
 * 
 * This class defines the formatting and layout of the
 * GUI for displaying Character Sheets.
 *
 * Change Log:
 * 	06/10/11 10:55 - (v1.0) Release
 * 	May 31, 2011 12:53:30 PM - (v0.1) Initial Implementation
 */

package gui;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

import ds.Character;
import resources.*;

public class CharacterPane extends JPanel implements ActionListener
{
	private static final long serialVersionUID = 2334792392154867031L;

	private final boolean DEBUG = true;
	
	private JPanel jp_stats = new JPanel(new GridBagLayout());
		private JLabel jl_level = new JLabel("Level");	
		private JLabel jl_str = new JLabel("Str:");
		private JLabel jl_agi = new JLabel("Agi: ");
		private JLabel jl_int = new JLabel("Int: ");
		private JLabel jl_foc = new JLabel("Foc: ");
		private JLabel jl_con = new JLabel("Con: ");
		private JLabel jl_cha = new JLabel("Cha: ");
		private JButton jb_level = new JButton();
		private JButton jb_str = new JButton();
		private JButton jb_agi = new JButton();
		private JButton jb_int = new JButton();
		private JButton jb_foc = new JButton();
		private JButton jb_con = new JButton();
		private JButton jb_cha = new JButton();
		private JTextField jtf_level = new JTextField();
		private JTextField jtf_str = new JTextField();
		private JTextField jtf_agi = new JTextField();
		private JTextField jtf_int = new JTextField();
		private JTextField jtf_foc = new JTextField();
		private JTextField jtf_con = new JTextField();
		private JTextField jtf_cha = new JTextField();
		private JLabel jl_player;
		private JLabel jl_class; 
	
	private JPanel jp_lists = new JPanel(new GridBagLayout());
		private JButton jb_add_abil = new JButton("+");
		private JButton jb_rem_abil = new JButton("-");
		private JButton jb_add_skill = new JButton("+");
		private JButton jb_rem_skill = new JButton("-");
		private JButton jb_add_item = new JButton("+");
		private JButton jb_rem_item = new JButton("-");
		private JButton jb_add_creds = new JButton("Credits");
		private JTabbedPane jtp_abil_pow = new JTabbedPane();
			private JList jli_abilities;
			private JList jli_powers;
		private JTabbedPane jtp_inv = new JTabbedPane();
			private JList jli_inv;
			private JList jli_weps;
			private JList jli_armor;
		
	private GridBagConstraints gbc_main = new GridBagConstraints();
	private GridBagConstraints gbc_jp_stats = new GridBagConstraints();
	private GridBagConstraints gbc_jp_lists = new GridBagConstraints();
	
	private Character ch_data;
	
	/**
	 * CharacterPane
	 * 
	 * Default constructor for the CharacterPane object.
	 */
	
	public CharacterPane()
	{
		ch_data.setSName("Name");
		ch_data.setSClass("Class");
		ch_data.setSRace("Race");
		ch_data.setSPlayer("Player");
		ch_data.setILevel(1);
		ch_data.setIXP(0);
		ch_data.setIHP(6);
		ch_data.setIStr(10);
		ch_data.setIAgi(10);
		ch_data.setIInt(10);
		ch_data.setIFoc(10);
		ch_data.setICon(10);
		ch_data.setICha(10);
		ch_data.setICreds(0);
		init();
	}
	
	/**
	 * Overloaded single parameter constructor for
	 * CharacterPane objects.
	 * 
	 * @param init_ch_data Character data structure to display
	 */
	
	public CharacterPane(Character init_ch_data)
	{		
		ch_data = init_ch_data;
		init();
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent event)
	{
		//E_AddType eat_list;
		
		/* Stat Buttons */
		
		if(event.getSource().equals(jb_level))
		{
			jb_level.setVisible(false);
			jtf_level.setEditable(true);
			jtf_level.setFocusable(true);
			jtf_level.setVisible(true);
			jtf_level.requestFocusInWindow();
			jtf_level.selectAll();
		}
		
		if(event.getSource().equals(jb_str))
		{
			try
			{
				jtf_str.setEditable(!jtf_str.isEditable());
				jtf_str.setFocusable(!jtf_str.isFocusable());
				
				if(!jtf_str.isEditable())
				{
					ch_data.setIStr(Integer.parseInt(jtf_str.getText()));
					jb_str.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIStr())));
				}
				
				else
				{
					jtf_str.requestFocusInWindow();
					jtf_str.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_str.setText(Integer.toString(ch_data.getIStr()));
			}
			
			catch(NullPointerException e)
			{
				jb_str.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jb_agi))
		{
			try
			{
				jtf_agi.setEditable(!jtf_agi.isEditable());
				jtf_agi.setFocusable(!jtf_agi.isFocusable());
				
				if(!jtf_agi.isEditable())
				{
					ch_data.setIAgi(Integer.parseInt(jtf_agi.getText()));
					jb_agi.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIAgi())));
				}
				
				else
				{
					jtf_agi.requestFocusInWindow();
					jtf_agi.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_agi.setText(Integer.toString(ch_data.getIAgi()));
			}
			
			catch(NullPointerException e)
			{
				jb_str.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jb_int))
		{
			try
			{
				jtf_int.setEditable(!jtf_int.isEditable());
				jtf_int.setFocusable(!jtf_int.isFocusable());
				
				if(!jtf_int.isEditable())
				{
					ch_data.setIInt(Integer.parseInt(jtf_int.getText()));
					jb_int.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIInt())));
				}
				
				else
				{
					jtf_int.requestFocusInWindow();
					jtf_int.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_int.setText(Integer.toString(ch_data.getIInt()));
			}
			
			catch(NullPointerException e)
			{
				jb_int.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jb_foc))
		{
			try
			{
				jtf_foc.setEditable(!jtf_foc.isEditable());
				jtf_foc.setFocusable(!jtf_foc.isFocusable());
				
				if(!jtf_foc.isEditable())
				{
					ch_data.setIFoc(Integer.parseInt(jtf_foc.getText()));
					jb_foc.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIFoc())));
				}
				
				else
				{
					jtf_foc.requestFocusInWindow();
					jtf_foc.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_foc.setText(Integer.toString(ch_data.getIFoc()));
			}
			
			catch(NullPointerException e)
			{
				jb_foc.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jb_con))
		{
			try
			{
				jtf_con.setEditable(!jtf_con.isEditable());
				jtf_con.setFocusable(!jtf_con.isFocusable());
				
				if(!jtf_con.isEditable())
				{
					ch_data.setICon(Integer.parseInt(jtf_con.getText()));
					jb_con.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICon())));
				}
				
				else
				{
					jtf_con.requestFocusInWindow();
					jtf_con.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_con.setText(Integer.toString(ch_data.getICon()));
			}
			
			catch(NullPointerException e)
			{
				jb_con.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jb_cha))
		{
			try
			{
				jtf_cha.setEditable(!jtf_cha.isEditable());
				jtf_cha.setFocusable(!jtf_cha.isFocusable());
				
				if(!jtf_cha.isEditable())
				{
					ch_data.setICha(Integer.parseInt(jtf_cha.getText()));
					jb_cha.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICha())));
				}
				
				else
				{
					jtf_cha.requestFocusInWindow();
					jtf_cha.selectAll();
				}
			}
			
			catch(NumberFormatException e)
			{
				jtf_cha.setText(Integer.toString(ch_data.getICha()));
			}
			
			catch(NullPointerException e)
			{
				jb_cha.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		/* Stat Fields */
		
		if(event.getSource().equals(jtf_level))
		{
			try
			{
				ch_data.setILevel(Integer.parseInt(jtf_level.getText()));
				jtf_level.setEditable(false);
				jtf_level.setFocusable(false);
				jtf_level.setVisible(false);
				jb_level.setText(Integer.toString(ch_data.getILevel()));
				jb_level.setVisible(true);
			}
			
			catch(NumberFormatException e)
			{
				jtf_level.setEditable(false);
				jtf_level.setEditable(false);
				jtf_level.setFocusable(false);
				jtf_level.setVisible(false);
				jtf_level.setText(Integer.toString(ch_data.getILevel()));
				jb_level.setVisible(true);
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_str))
		{
			try
			{
				ch_data.setIStr(Integer.parseInt(jtf_str.getText()));
				jtf_str.setEditable(false);
				jtf_str.setFocusable(false);
				jb_str.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIStr())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_str.setEditable(false);
				jtf_str.setFocusable(false);
				jtf_str.setText(Integer.toString(ch_data.getIStr()));
			}
			
			catch(NullPointerException e)
			{
				jb_str.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_agi))
		{
			try
			{
				ch_data.setIAgi(Integer.parseInt(jtf_agi.getText()));
				jtf_agi.setEditable(false);
				jtf_agi.setFocusable(false);
				jb_agi.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIAgi())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_agi.setEditable(false);
				jtf_agi.setFocusable(false);
				jtf_agi.setText(Integer.toString(ch_data.getIAgi()));
			}
			
			catch(NullPointerException e)
			{
				jb_agi.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_int))
		{
			try
			{
				ch_data.setIInt(Integer.parseInt(jtf_int.getText()));
				jtf_int.setEditable(false);
				jtf_int.setFocusable(false);
				jb_int.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIInt())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_int.setEditable(false);
				jtf_int.setFocusable(false);
				jtf_int.setText(Integer.toString(ch_data.getIInt()));
			}
			
			catch(NullPointerException e)
			{
				jb_int.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_foc))
		{
			try
			{
				ch_data.setIFoc(Integer.parseInt(jtf_foc.getText()));
				jtf_foc.setEditable(false);
				jtf_foc.setFocusable(false);
				jb_foc.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIFoc())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_foc.setEditable(false);
				jtf_foc.setFocusable(false);
				jtf_foc.setText(Integer.toString(ch_data.getIFoc()));
			}
			
			catch(NullPointerException e)
			{
				jb_foc.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_con))
		{
			try
			{
				ch_data.setICon(Integer.parseInt(jtf_con.getText()));
				jtf_con.setEditable(false);
				jtf_con.setFocusable(false);
				jb_con.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICon())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_con.setEditable(false);
				jtf_con.setFocusable(false);
				jtf_con.setText(Integer.toString(ch_data.getICon()));
			}
			
			catch(NullPointerException e)
			{
				jb_con.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		if(event.getSource().equals(jtf_cha))
		{
			try
			{
				ch_data.setICha(Integer.parseInt(jtf_cha.getText()));
				jtf_cha.setEditable(false);
				jtf_cha.setFocusable(false);
				jb_cha.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICha())));
			}
			
			catch(NumberFormatException e)
			{
				jtf_cha.setEditable(false);
				jtf_cha.setFocusable(false);
				jtf_cha.setText(Integer.toString(ch_data.getICha()));
			}
			
			catch(NullPointerException e)
			{
				jb_cha.setText("~");
			}
			
			catch(Exception e)
			{
				System.err.println(e);
			}
		}
		
		/* Add/Remove Buttons */
		
		if(event.getSource().equals(jb_add_abil))
		{
			
		}
		
		if(event.getSource().equals(jb_add_skill))
		{
			
		}
		
		if(event.getSource().equals(jb_add_item))
		{
			
		}
		
		if(event.getSource().equals(jb_add_creds))
		{
			new ModCreditsPopUp(ch_data, jb_add_creds);
		}
	}
	
	public Character getChar() { return ch_data; }
	
	/**
	 * init
	 * 
	 * Initializes all of the components in the
	 * CharacterPane so that they can be displayed.
	 */
	
	private void init()
	{
		setName(ch_data.getSName());
		setLayout(new GridBagLayout());
		
		//for debugging only
		if(DEBUG)
		{
			//ch_data.setSClass("Smuggler");
			//ch_data.setSRace("Vosh");
			//ch_data.setSPlayer("Joe Scharnitzke");
			
			String[] s_list_items = {"Test"};
			jli_abilities = new JList(s_list_items);
			jli_powers = new JList(s_list_items);
			jli_inv = new JList(s_list_items);
			jli_weps = new JList(s_list_items);
			jli_armor = new JList(s_list_items);
		}
		
		jli_abilities.setName("Abilities");
		jli_powers.setName("Powers");
		jli_inv.setName("Inventory");
		jli_weps.setName("Weapons");
		jli_armor.setName("Armor");
		
		jtf_level.setEditable(false);
		jtf_str.setEditable(false);
		jtf_agi.setEditable(false);
		jtf_int.setEditable(false);
		jtf_foc.setEditable(false);
		jtf_con.setEditable(false);
		jtf_cha.setEditable(false);
		
		jtf_level.setFocusable(false);
		jtf_str.setFocusable(false);
		jtf_agi.setFocusable(false);
		jtf_int.setFocusable(false);
		jtf_foc.setFocusable(false);
		jtf_con.setFocusable(false);
		jtf_cha.setFocusable(false);
		
		jb_add_creds.setText(ch_data.getICreds() + " Credits");
		
		jl_player = new JLabel(ch_data.getSPlayer());
		jl_class = new JLabel(ch_data.getSClass());
		jb_level.setText(Integer.toString(ch_data.getILevel()));
		jb_str.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIStr())));
		jb_agi.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIAgi())));
		jb_int.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIInt())));
		jb_foc.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getIFoc())));
		jb_con.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICon())));
		jb_cha.setText(Integer.toString(StatModifiers.dnd35Standard().get(ch_data.getICha())));
		
		jtf_level.setText(Integer.toString(ch_data.getILevel()));
		jtf_str.setText(Integer.toString(ch_data.getIStr()));
		jtf_agi.setText(Integer.toString(ch_data.getIAgi()));
		jtf_int.setText(Integer.toString(ch_data.getIInt()));
		jtf_foc.setText(Integer.toString(ch_data.getIFoc()));
		jtf_con.setText(Integer.toString(ch_data.getICon()));
		jtf_cha.setText(Integer.toString(ch_data.getICha()));
		
		jb_level.addActionListener(this);
		jb_str.addActionListener(this);
		jb_agi.addActionListener(this);
		jb_int.addActionListener(this);
		jb_foc.addActionListener(this);
		jb_con.addActionListener(this);
		jb_cha.addActionListener(this);
		
		jb_add_abil.addActionListener(this);
		jb_rem_abil.addActionListener(this);
		jb_add_skill.addActionListener(this);
		jb_rem_skill.addActionListener(this);
		jb_add_item.addActionListener(this);
		jb_rem_item.addActionListener(this);
		jb_add_creds.addActionListener(this);
		
		jtf_level.addActionListener(this);
		jtf_str.addActionListener(this);
		jtf_agi.addActionListener(this);
		jtf_int.addActionListener(this);
		jtf_foc.addActionListener(this);
		jtf_con.addActionListener(this);
		jtf_cha.addActionListener(this);
		
		jl_class.setToolTipText(ch_data.getSRace());
		jl_level.setToolTipText("XP: " + Integer.toString(ch_data.getIXP()));
		jl_con.setToolTipText("HP: " + Integer.toString(ch_data.getIHP()));
		
		jtf_level.setVisible(false);
		
		/* Add labels to jp_stats */
		
		//add jl_player to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 0;
		gbc_jp_stats.gridwidth = 3;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_player, gbc_jp_stats);
		
		//add jl_level to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 1;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_level, gbc_jp_stats);
		
		//add jl_class to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 1;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_class, gbc_jp_stats);
		
		//add jl_str to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 2;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_str, gbc_jp_stats);
		
		//add jl_agi to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 3;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_agi, gbc_jp_stats);
		
		//add jl_int to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 4;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_int, gbc_jp_stats);
		
		//add jl_foc to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 5;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_foc, gbc_jp_stats);
		
		//add jl_con to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 6;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_con, gbc_jp_stats);
		
		//add jl_cha to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 0;
		gbc_jp_stats.gridy = 7;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jl_cha, gbc_jp_stats);
		
		/* Add buttons to jp_stats */
		
		//add jb_level to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 1;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_level, gbc_jp_stats);
		
		//add jb_str to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 2;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_str, gbc_jp_stats);
		
		//add jb_agi to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 3;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_agi, gbc_jp_stats);
		
		//add jb_int to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 4;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_int, gbc_jp_stats);
		
		//add jb_foc to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 5;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_foc, gbc_jp_stats);
		
		//add jb_con to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 6;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_con, gbc_jp_stats);
		
		//add jb_cha to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 2;
		gbc_jp_stats.gridy = 7;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jb_cha, gbc_jp_stats);
		
		/* Add text fields to jp_stats */
		
		//add jtf_level to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 1;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_level, gbc_jp_stats);
		
		//add jtf_str to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 2;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_str, gbc_jp_stats);
		
		//add jtf_agi to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 3;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_agi, gbc_jp_stats);
		
		//add jtf_int to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 4;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_int, gbc_jp_stats);
		
		//add jtf_foc to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 5;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_foc, gbc_jp_stats);
		
		//add jtf_con to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 6;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_con, gbc_jp_stats);
		
		//add jtf_cha to jp_stats
		gbc_jp_stats.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_stats.gridx = 1;
		gbc_jp_stats.gridy = 7;
		gbc_jp_stats.gridwidth = 1;
		gbc_jp_stats.weightx = 1.0;
		gbc_jp_stats.weighty = 1.0;
		gbc_jp_stats.insets = new Insets(2, 5, 2, 5);
		jp_stats.add(jtf_cha, gbc_jp_stats);
		
		/* Add buttons to jp_lists */
		
		//add jb_add_abil to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.NONE;
		gbc_jp_lists.gridx = 0;
		gbc_jp_lists.gridy = 5;
		gbc_jp_lists.gridwidth = 1;
		gbc_jp_lists.gridheight = 1;
		gbc_jp_lists.weightx = 0.0;
		gbc_jp_lists.weighty = 0.0;
		gbc_jp_lists.insets = new Insets(2, 2, 2, 2);
		jp_lists.add(jb_add_abil, gbc_jp_lists);
		
		//add jb_rem_abil to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.NONE;
		gbc_jp_lists.gridx = 1;
		gbc_jp_lists.gridy = 5;
		gbc_jp_lists.gridwidth = 1;
		gbc_jp_lists.gridheight = 1;
		gbc_jp_lists.weightx = 0.0;
		gbc_jp_lists.weighty = 0.0;
		gbc_jp_lists.insets = new Insets(2, 2, 2, 2);
		jp_lists.add(jb_rem_abil, gbc_jp_lists);
		
		//add jb_add_item to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.NONE;
		gbc_jp_lists.gridx = 0;
		gbc_jp_lists.gridy = 10;
		gbc_jp_lists.gridwidth = 1;
		gbc_jp_lists.gridheight = 1;
		gbc_jp_lists.weightx = 0.0;
		gbc_jp_lists.weighty = 0.0;
		gbc_jp_lists.insets = new Insets(2, 2, 2, 2);
		jp_lists.add(jb_add_item, gbc_jp_lists);
		
		//add jb_rem_item to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.NONE;
		gbc_jp_lists.gridx = 1;
		gbc_jp_lists.gridy = 10;
		gbc_jp_lists.gridwidth = 1;
		gbc_jp_lists.gridheight = 1;
		gbc_jp_lists.weightx = 0.0;
		gbc_jp_lists.weighty = 0.0;
		gbc_jp_lists.insets = new Insets(2, 2, 2, 2);
		jp_lists.add(jb_rem_item, gbc_jp_lists);
		
		//add jb_add_creds to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.HORIZONTAL;
		gbc_jp_lists.gridx = 8;
		gbc_jp_lists.gridy = 10;
		gbc_jp_lists.gridwidth = 2;
		gbc_jp_lists.gridheight = 1;
		gbc_jp_lists.weightx = 0.0;
		gbc_jp_lists.weighty = 0.0;
		gbc_jp_lists.insets = new Insets(2, 5, 2, 5);
		jp_lists.add(jb_add_creds, gbc_jp_lists);
		
		/* Add tabbed panes to jp_lists */
		
		//add jtp_inv to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.BOTH;
		gbc_jp_lists.gridx = 0;
		gbc_jp_lists.gridy = 6;
		gbc_jp_lists.gridwidth = 10;
		gbc_jp_lists.gridheight = 4;
		gbc_jp_lists.weightx = 1.0;
		gbc_jp_lists.weighty = 1.0;
		gbc_jp_lists.insets = new Insets(2, 5, 2, 5);
		jp_lists.add(jtp_inv, gbc_jp_lists);
		
		//add jtp_abil_pow to jp_lists
		gbc_jp_lists.fill = GridBagConstraints.BOTH;
		gbc_jp_lists.gridx = 0;
		gbc_jp_lists.gridy = 0;
		gbc_jp_lists.gridwidth = 10;
		gbc_jp_lists.gridheight = 4;
		gbc_jp_lists.weightx = 1.0;
		gbc_jp_lists.weighty = 1.0;
		gbc_jp_lists.insets = new Insets(2, 5, 2, 5);
		jp_lists.add(jtp_abil_pow, gbc_jp_lists);
		
		/* Add lists to jtp_inv */
		
		jtp_inv.add(jli_inv);
		jtp_inv.add(jli_weps);
		jtp_inv.add(jli_armor);
		
		/* Add lists to jtp_abil_pow */
		
		jtp_abil_pow.add(jli_abilities);
		jtp_abil_pow.add(jli_powers);
		
		/* Add panels to this */
		
		//add jp_stats to this
		gbc_main.fill = GridBagConstraints.NONE;
		gbc_main.gridx = 0;
		gbc_main.gridy = 0;
		gbc_main.gridwidth = 1;
		gbc_main.gridheight = 1;
		gbc_main.weightx = 0.0;
		gbc_main.weighty = 0.0;
		gbc_main.insets = new Insets(2, 2, 2, 2);
		gbc_main.anchor = GridBagConstraints.NORTHWEST;
		add(jp_stats, gbc_main);
		
		//add jp_lists to this
		gbc_main.fill = GridBagConstraints.BOTH;
		gbc_main.gridx = 1;
		gbc_main.gridy = 0;
		gbc_main.gridwidth = 1;
		gbc_main.gridheight = 1;
		gbc_main.weightx = 1.0;
		gbc_main.weighty = 1.0;
		gbc_main.insets = new Insets(2, 2, 2, 2);
		gbc_main.anchor = GridBagConstraints.NORTH;
		add(jp_lists, gbc_main);
	}
}
